﻿@using WB.Core.BoundedContexts.Headquarters.Resources
@using WB.Core.BoundedContexts.Headquarters.Workspaces
@using WB.Core.SharedKernels.SurveyManagement.Web.Models
@using WB.UI.Headquarters.Services
@using WB.UI.Shared.Web.Extensions
@{
    var page = ViewBag.ActivePage ?? MenuItem.Logon;
}
<ul class="nav navbar-nav">
    <li class="dropdown @(page == MenuItem.MapReport || page == MenuItem.Surveys || page == MenuItem.SurveyAndStatuses || page == MenuItem.Summary || page == MenuItem.Statuses || page == MenuItem.DevicesInterviewers || page == MenuItem.StatusDuration || page == MenuItem.InterviewsChart ? "active" : "")">
        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" title="@MainMenu.Reports">
            @MainMenu.Reports <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
            @Html.MainMenuItem("SurveysAndStatuses", "Reports", @MainMenu.SurveysAndStatuses, MenuItem.SurveyAndStatuses)
            @Html.MainMenuItem("SupervisorsAndStatuses", "Reports", @MainMenu.TeamsAndStatuses, MenuItem.Summary)
            @Html.MainMenuItem("StatusDuration", "Reports", @MainMenu.StatusDuration, MenuItem.StatusDuration)
            @Html.MainMenuItem("InterviewersAndDevices", "Reports", @MainMenu.DevicesInterviewers, MenuItem.DevicesInterviewers)
            @Html.MainMenuItem("MapReport", "Reports", @MainMenu.MapReport, MenuItem.MapReport)
            @Html.MainMenuItem("InterviewsChart", "Reports", @MainMenu.CumulativeChart, MenuItem.InterviewsChart)
            @Html.MainMenuItem("QuantityBySupervisors", "Reports", @MainMenu.Quantity, MenuItem.NumberOfCompletedInterviews)
            @Html.MainMenuItem("SpeedBySupervisors", "Reports", @MainMenu.Speed, MenuItem.SpeedOfCompletingInterviews)
            @Html.MainMenuItem("SurveyStatistics", "Reports", @MainMenu.SurveyStatistics, MenuItem.SurveyStatistics)
        </ul>
    </li>
    @Html.MainMenuItem("Index", "Interviews", @MainMenu.Interviews, MenuItem.Interviews)
    <li class="dropdown  @(page == MenuItem.Questionnaires || page == MenuItem.Assignments || page == MenuItem.Maps ? "active" : "")">
        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" title="@MainMenu.SurveySetup">
            @MainMenu.SurveySetup <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
            @Html.MainMenuItem("Index", "SurveySetup", @MainMenu.Questionnaires, MenuItem.Questionnaires)
            @Html.MainMenuItem("Index", "Assignments", @MainMenu.Assignments, MenuItem.Assignments)
            @Html.MainMenuItem("Index", "Maps", @MainMenu.Maps, MenuItem.Maps)
        </ul>
    </li>
    @Html.MainMenuItem("New", "DataExport", @MainMenu.DataExport, MenuItem.DataExport)
    
    <li class="dropdown  @(page == MenuItem.Settings || page == MenuItem.EmailProviders || page == MenuItem.TabletLogs 
                           || page == MenuItem.AuditLog || page == MenuItem.Administration_InterviewPackages ? "active" : "")">
            <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" title="@MainMenu.Settings">
                @MainMenu.Settings <span class="caret"></span>
            </a>
        <ul class="dropdown-menu">
            @Html.MainMenuItem("Index", "Settings", @MainMenu.WorkspaceSettings, MenuItem.WorkspaceSettings)
            @Html.MainMenuItem("EmailProviders", "Settings", @MainMenu.EmailProviders, MenuItem.EmailProviders)
            
            @Html.MainMenuItem("AuditLog", "Diagnostics", @MainMenu.AuditLog, MenuItem.AuditLog)
            @Html.MainMenuItem("InterviewPackages", "Diagnostics", @MainMenu.InterviewPackages, MenuItem.Administration_InterviewPackages)
            @Html.MainMenuItem("Logs", "Diagnostics", @MainMenu.DeviceLogs, MenuItem.TabletLogs)
        </ul>
    </li>
    
    @if (ViewContext.RouteData.Values["controller"].ToString() == "ControlPanel")
    {
        <li class="dropdown  @(new[] { MenuItem.Administration_AppUpdates, MenuItem.Administration_Config, MenuItem.Administration_InterviewPackages, MenuItem.Administration_Exceptions, MenuItem.Administration_ChangePassword, MenuItem.Administration_ReevaluateInterview }.Contains((MenuItem)page) ? "active" : "")">
            <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" title="@MainMenu.Administration">
                @MainMenu.Administration <span class="caret"></span>
            </a>
            <ul class="dropdown-menu">
                @Html.MainMenuItem("Configuration", "ControlPanel", Pages.Configuration, MenuItem.Administration_Config)
                @Html.MainMenuItem("AppUpdates", "ControlPanel", Pages.AppUpdates, MenuItem.Administration_AppUpdates)
                @Html.MainMenuItem("Exceptions", "ControlPanel", Pages.Exceptions, MenuItem.Administration_Exceptions)
                @Html.MainMenuItem("ReevaluateInterview", "ControlPanel", Pages.ReevaluateInterview, MenuItem.Administration_ReevaluateInterview)
            </ul>
        </li>
    }
</ul>
<ul class="nav navbar-nav navbar-right">
    @if (User.IsInRole("Administrator"))
    {
        <li>
            <a href="@Url.ContentAtWorkspace(Workspace.Admin.AsContext(), "Workspaces")"></a>
        </li>


        <li>
            <a href="@Url.ContentAtWorkspace(Workspace.Admin.AsContext(), "Workspaces")" class="icon-link" title="@MainMenu.ServerAdministration">
                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="icon" viewBox="0 0 16 16">
                    <path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492zM5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0z"/>
                    <path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52l-.094-.319zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.377l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115l.094-.319z"/>
                </svg>
            </a>
        </li>
    }

    <li>
        <a href="https://docs.mysurvey.solutions/headquarters" target="_blank" class="icon-link" title="@MainMenu.Help">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="icon" viewBox="0 0 16 16">
                <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
                <path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>
            </svg>
        </a>
    </li>
    <li class="dropdown @(page == MenuItem.ManageAccount ? "active" : "")">
        <a href="javascript:void(0);" class="dropdown-toggle toggle-sized" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" title="@User.Identity.Name">
            @User.Identity.Name<span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
            @Html.MainMenuItem(Workspace.UsersWorkspace.AsContext(), "Manage", "Users", Strings.SurverManagement_MainMenu_ManageAccount, MenuItem.ManageAccount)
            <li>
                <a href="/Account/LogOff">@Common.Logoff</a>
            </li>
        </ul>
    </li>
</ul>
